package com.yunhui.admin.web.comment;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yunhui.admin.utils.PaginationService;
import com.yunhui.entity.Comment;
import com.yunhui.mapper.CommentMapper;


@Controller
@RequestMapping("${yunhui.admin.urlContext}")
public class CommentManagController {

	@Autowired
	private PaginationService paginationService;
	
	@Autowired
	private CommentMapper commentMapper;
	
	
	/**

	 * @return
	 */
	@RequestMapping("/comment/manage/commentList")
	@ResponseBody
	public Object getCommentList(HttpServletRequest request,HttpServletResponse response) {
		//返回值
		Map<String, Object> resutlMap = new HashMap<>();
		//参数集合
		Map<String, Object> paramMap = new HashMap<>();
		//绑定分页控件
		paginationService.encapSearchPaginationCondition(request, paramMap);
		
		Long total = commentMapper.getCommentCount(paramMap);
		// 返回结果
		List<Comment> list = new ArrayList<Comment>();
		if(total>0) {
			list = commentMapper.getCommentList(paramMap);
		}
		resutlMap.put("total", total);
		resutlMap.put("rows", list);
		return resutlMap;
	}
}
